import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Article from '../views/Article.vue'
import Message from '../views/Message.vue'
import Login from '../views/Login.vue'
import ArticleDetail from '../views/ArticleDetail.vue';

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/article',
    name: 'Article',
    component: Article
  },
  {
    path: '/message',
    name: 'Message',
    component: Message
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  }, {
    path: '/articleDetail/:titleId',
    name: 'ArticleDetail',
    component: ArticleDetail
  }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
